package znbkDialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.lancooznbk.R;

import static znbkTestPaperNtxl.activity.TrainingDifficultProblemsPaperActivity.mEntityNtxl;

/**
 * Created by Administrator on 2018\3\26 0026.
 */

public class ZnbkDialogSubmitFeedBack extends Dialog {

    private Context mContext;
    private ClickListenerInterface clickListenerInterface;
    public static Button mBtnCheck;
    public static Button mBtnBack;
    public static TextView mTvDialogTitle;
    public static LinearLayout LayoutButton;



    public interface ClickListenerInterface {
        public void doCheck();
        public void doBack();
    }

    public ZnbkDialogSubmitFeedBack(Context context) {
        super(context, R.style.CustomDialog);
        this.mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        init();

        getWindow().setBackgroundDrawableResource(R.color.vifrification);
    }

    public void init() {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        View view = inflater.inflate(R.layout.znbk_dialog_submit_feed_back, null);
        setContentView(view);

        mTvDialogTitle = (TextView) findViewById(R.id.tv_dialogTitle);
        if(mEntityNtxl.getCorrectRate()<0.7){
            mTvDialogTitle.setText("本次学习未通过");
        }else{
            mTvDialogTitle.setText("本次学习通过");
        }

        mBtnCheck = (Button) findViewById(R.id.btn_check);
        mBtnCheck.setOnClickListener(new clickListener());

        mBtnBack = (Button) findViewById(R.id.btn_back);
        mBtnBack.setOnClickListener(new clickListener());

        LayoutButton = (LinearLayout) findViewById(R.id.layout_button);

        setCanceledOnTouchOutside(false);


    }

    public void setClicklistener(ClickListenerInterface clickListenerInterface) {
        this.clickListenerInterface = clickListenerInterface;
    }


    private class clickListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            int id = v.getId();
            switch (id) {
                case R.id.btn_check:
                    clickListenerInterface.doCheck();
                    break;

                case R.id.btn_back:
                    clickListenerInterface.doBack();
                    break;

                default:
                    System.out.println("-----ooooooo11111defalt----------------");
                    break;
            }
        }

    };

}